#include "stdio.h"
#include "string.h"
#include "tcs_struct.h"
#include "tcs_struct_operator.h"
#include "msgQLib.h"

const int NUM_PRI = 6;
int pri[] = {7, 4, 2, 8, 5, 1};

void initMsgAskTest(MSG_Ask * pmsgAsk) {
    static int index = 0;
    int i = index % NUM_PRI;
    index ++;
    pmsgAsk->priority = pri[i];
    pmsgAsk->trustAskSt = NULL;
}

void tcs_struct_test() {
    const int NUM_TST = 10;
	M_MSG_Head m_MSG_Head;
    int i;
    MSG_Ask msgAsk;
    MSG_Ask tmpAsk;
	tcs_mStruct_init(&m_MSG_Head);
	printf("\n\n\n&&&&&&&&&&\n");
    for(i = 0; i < NUM_TST / 2; i++) {
        initMsgAskTest(&msgAsk);
        tcs_mStruct_append(msgAsk, &m_MSG_Head);
        displayQ(m_MSG_Head);
    }
    for(i = 0; i < NUM_TST / 2; i++) {
        initMsgAskTest(&msgAsk);
        tcs_mStruct_getUrgentest(&tmpAsk, &m_MSG_Head);
        displayQ(m_MSG_Head);
        tcs_mStruct_append(msgAsk, &m_MSG_Head);
        displayQ(m_MSG_Head);
    }
    for(i = 0; i < NUM_TST / 2; i++) {
        tcs_mStruct_getUrgentest(&tmpAsk, &m_MSG_Head);
        displayQ(m_MSG_Head);
    }
}
